home *** CD-ROM | disk | FTP | other *** search
-
- How to overcome the limit on open files imposed by MS/PC-DOS
-
- The following procedure has been tested and found working under DOS 3.1.
- It may not work under DOS 2.1 (I tested it once and it failed) but the
- patch won't have any effect on program operation under 2.1.
-
- NOTE - this is not a patch to DOS; it is a patch applied to the user
- program and must be incorporated at assembly/compile time.
-
-
- Regardless of the FILES= variable in CONFIG.SYS, DOS imposes an arbitrary
- limit of 20 simultaneously open files per process. That number includes
- the five pre-opened standard files, STDIN, STDOUT, STDERR, STDAUX and STDPRN.
- Under normal circumstances, the resulting limit of 15 simultaneously open
- user files is quite sufficient. If you application, however, requires access
- to more than 15 files, and if you don't feel like closing and reopening files
- to remain within the 15-file limit, you might want to consider adding the
- follwing patch to your program source.
-
- DESCRIPTION of the patch -- you code it:
-
- PSP+18H contains a table of 20 file handles. When a program is invoked,
- normally only the first 5 handles are open, all others are 0FFH.
-
- PSP+32H contains a word value that signifies the maximum number of open
- files for the process. This number is 14H (20) by default.
-
- PSP+34H contains the offset to the file handle table (18H default).
-
- PSP+36H contains the segment address of the file handle table (default is
- same as the PSP's data segment).
-
-
- To extend the number of simultaneously open files, your program must do the
- following in sequence and before opening any files:
-
- 1. Provide a data block containing a 0FFH byte for each file you wish to
- be able to open simultaneously.
-
- 2. Copy the first 20 bytes of the table at PSP+18H into the beginning of
- the new data block.
-
- 3. change the segment address at PSP+36H and the offset at PSP+34H to point
- to the new data block.
-
- 4. change the count at PSP+32H to the new count, which must not exceed the
- size of the new data block.
-
- 5. continue normally with program execution.
-
- Note that no I/O whatsoever must occur between steps 2 and 5!
-
- You can test the change by repeatedly opening a file until an error occurs.
- The following program fragment assumes that PSP-segment = DS = ES:
-
- code segment:
- MOV SI,18H
- MOV DI,Offset PFT
- MOV Word Ptr .34H,DI
- MOV CX,10
- REP MOVSW ; COPY OLD PROCESS FILE TABLE
- MOV AX,ES
- MOV Word Ptr .36H,AX
- MOV Byte Ptr .32H,MAXFLS
- data segment:
- PFT DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH......
-
-
- Be sure to change the FILES= variable in CONFIG.SYS to a number at least as
- large as PSP+32H.